#pragma once

#include "../ecs/ecs.hpp"

#include "./ellipse/ellipse.hpp"
#include "./fan/fan.hpp"
#include "./key_point/keyPoint.hpp"
#include "./label/label.hpp"
#include "./onlyread/onlyread.hpp"
#include "./path/path.hpp"
#include "./pin/pin.hpp"
#include "./polygon/polygon.hpp"
#include "./rectangle/rectangle.hpp"
#include "./ruler/ruler.hpp"
#include "./text/text.hpp"

#include "./section_area_3d/section_area_3d.hpp"
#include "./view_area_3d/view_area_3d.hpp"

#include "./add_ref/add_ref.hpp"

#include "./components.hpp"
#include "./events.hpp"

namespace qbe::draw {

void clear_event(ecs::Query query);

class DrawPlugin : public ecs::Plugin {
 public:
  void build(ecs::App& app) override {
    app.init_event<Event>();

    app.add_plugins(AddRef::AddRefPlugin());

    app.add_plugins(polygon::Plugin());
    app.add_plugins(path::Plugin());
    app.add_plugins(label::Plugin());
    app.add_plugins(ellipse::Plugin());
    app.add_plugins(text::Plugin());
    app.add_plugins(ruler::Plugin());
    app.add_plugins(rectangle::Plugin());
    app.add_plugins(fan::Plugin());
    app.add_plugins(onlyread::OnlyReadPlugin());
    app.add_plugins(pin::Plugin());
    app.add_plugins(keyPoint::Plugin());

    app.add_plugins(view_area_3d::Plugin());
    app.add_plugins(section_area_3d::Plugin());

    app.add_systems<ecs::stage::Last>(clear_event);
  };
};
}  // namespace qbe::draw